<?php defined('IN_YuLin') || exit('NO PERMIT!'); ?>
{template index/header}
	<div class="container containerUser fix pt15">
		{template member/slide}
		<div class="userRight">
			<div class="userTitle mgb10">下级开户</div> 
			<div class="userMain openAgent mgb10">
				<div class="newTab">
					<a href="{U('member/manageInvite')}" class="">下级开户</a> 
					<a href="javascript:void(0);" class="curr">邀请码管理</a>
				</div> 
				<div data-id="1" data-title="" class="TabLi">
					<div class="TabLi">
                       	<ul class="searchFirst">
                        	<li>
                        		<span>开户类型：</span> 
                        		<a href="{U('member/manageInvite', array('operation'=>'managecode', 'type'=>'1'))}" class="userSearch {if $type == 1}active{/if}" amv="1">代理</a> 
                        		<a href="{U('member/manageInvite', array('operation'=>'managecode', 'type'=>'2'))}" class="userSearch {if $type == 2}active{/if}" amv="2">玩家</a>
                        	</li>
                       	</ul> 
                       	<div class="invitationCode">
                        	<div class="notContent" style="padding: 100px 0px; display: none;">
                         		<div class="iconLoadingCon" style="transform: scale(0.6);">
                          			<img src="//imagess-google.com/system/mobile/lottery/loadingMobile.gif" alt="" class="loadingImg" />
                         		</div>
                        	</div> 
                        	<table width="100%" border="0" margin="0" padding="0" cellspacing="0" cellpadding="0" class="manageInvite" id="id_code_list">
                         		<tbody>
                          			<tr>
                                   		<th>邀请码</th>
                                   		<th>注册链接</th>
                                   		<th>备注</th>
                                   		<th>生成时间</th>
                                   		<th>状态</th>
                                   		<th>操作</th>
                          			</tr> 
                         		</tbody>
                        	</table> 
                        	<div class="page" style="">
                         		<p>共<em id="id_invcode_count">3</em>条记录</p> 
                         		<div id="pageNav" class="pageNav">
                          			<ul class="pagination" style="display: none;">
                                   		<li style="display: none;"><a>上一页</a></li> 
                                       	<li class="active"><a>1</a></li> 
                                       	<li style="display: none;"><a>下一页</a></li>
                          			</ul>
                         		</div>
                        	</div> 
                        	<div class="userTip mg30">
                         		<p><i class="iconfont"></i>温馨提示：“邀请码” 与 “注册链接” 功能一致，可以使用邀请码，也可以使用注册链接。</p>
                        	</div> 
                        	<div class="_div" style="display: none;" id="id_invcode_detail">
                         		<div class="layerBg"></div> 
                         		<div class="layerBox">
                       				<div move="ok" class="layui-layer-title" style="cursor: move;">详情</div> 
                       				<div id="" class="layui-layer-content" style="height: 450px;">
                        				<div id="Detail" class="bonusTable" style="padding: 0px;">
                        					{loop $cateList as $k => $v}
                        						<ul class="InviteW">
                                                	<li>{$v['name']}</li> 
                                                    <li>
                                                    	<input type="text" name="" disabled="disabled" class="userInput mgl20" id="id_invcode_item_{$v['id']}" />&nbsp;
                                                    	<span>（自身返点：{$rpsInfo[$k]['re_point']}）</span>
                                                    </li>
                                               	</ul>
                        					{/loop}
                        				</div>
                       				</div> 
                       				<span class="layui-layer-setwin"><a href="javascript:;" class="close" id="id_close_invcode"></a></span>
                      			</div>
                        	</div> 
                            <div class="_Info" style="display: none;">
                             	<div class="layerBg"></div> 
                             	<div class="layerMsg">
                              		<div class="layui-layer layui-layer-dialog layui-layer-prompt layer-anim">
                               			<div class="layui-layer-title" style="cursor: move;">备注</div> 
                               			<div id="" class="layui-layer-content">
                                			<input type="text" class="layui-layer-input" />
                               			</div> 
                               			<span class="layui-layer-setwin"><a href="javascript:;" class="close"></a></span> 
                               			<div class="layui-layer-btn">
                                			<a class="layui-layer-btn0">确定</a> 
                                			<a class="layui-layer-btn1">取消</a>
                               			</div>
                              		</div>
                             	</div>
                            </div>
                       	</div>
                  	</div>
                </div>
            </div>
        </div>
	</div>
	<input type="hidden" id="baseRegUrl" value="{$host . U('member/register')}"/>
	<script src="static/js/member/member_common_func.js"></script>
	<script>
		var type    = '';
		var resData = '';
		$.each($('.userSearch'), function (i, v){
			if ($(v).hasClass('active')){
				type = $(this).attr('amv');
				return false;
			}
		})
		var param   = {'operation':'getRpsByUid', 'type':type};
		getData("{U('json/func_member')}", param);
		$('#id_invcode_count').html(Object.keys(resData).length);
		var trStr  = '';
		var remark = '';
		var baseReg= $('#baseRegUrl').val();
		$.each(resData, function (i, v){
			remark = v.remark ? v.remark : '未设置';
			trStr  = '<tr amv="' + i + '">';
			trStr += '	<td><input type="text" class="code" value="' + v.invita_code + '"/> <span class="copybtn tag_copy_code" amv="' + v.id + '">复制</span></td>';
			trStr += '	<td><input type="text"  value="' + baseReg + '&key=' + v.invita_code + '"/> <span class="copybtn tag_copy_link" amv="' + v.id + '">复制</span></td>';
			trStr += '	<td><em class="xem">' + remark + '</em></td>';
			trStr += '	<td>' + v.re_createtime + '</td>';
			trStr += '	<td>注册(0)</td>';
			trStr += '	<td><a href="javascript:void(0);" class="detail tag_rps_detail" amv="' + i + '">详情</a> | <a href="javascript:void(0);" class="del tag_rps_delete" amv="' + i + '">删除</a></td>';
			trStr += '</tr>';
			$('#id_code_list').append(trStr);
		})
		
		// 点击查看详情
		$('#id_code_list').on('click', '.tag_rps_detail', function (){
			var detail = resData[$(this).attr('amv')].item;
			$('#id_invcode_detail').show();
			for(var i = 0; i < detail.length; i++){
				$('#id_invcode_item_' + detail[i].lott_cate_id).val(detail[i].re_point);
			}
		})
		$('#id_close_invcode').on('click', function (){
			$('#id_invcode_detail').hide();
		})
		$('#id_code_list').on('click', '.tag_rps_delete', function (){
			var cfm   = confirm('确定要删除该邀请码？');
			if(cfm){
				var delId = $(this).attr('amv');
				var param = {'operation':'deleteRps', 'id':delId};
				postRequest("{U('json/func_member')}", param);
				$('#id_code_list tr[amv="' + delId + '"]').remove();
			}
		})
		$('').ready(function(){
			var clipboard = new Clipboard('.btn');   
		   	clipboard.on('success', function(e) {  
		        alert("复制成功！")  
		        });  
		   	clipboard.on('error', function(e) {  
               	alert("复制失败！请手动复制")  
        	});  
		})
		
		$('#id_code_list').on('ready', '.tag_copy_code', function (){
			

		})
	</script>
{template index/footer}